f = open('p022_names.txt', 'r')

w = []

for line in f:
    line = line.strip().split(',')
    for word in line:
        w.append(word[1:-1])

w.sort()

ans = 0
b = ord('A')
for i in xrange(len(w)):
    score = 0
    for s in list(w[i]):
        score += ord(s) - b + 1
    score *= i + 1
    ans += score

print ans


